const canvas = document.getElementById('webgl')
const gl = getWebGLContext(canvas)//使用封装好的，来适应不同brower

//顶点着色器 指定点的位置和尺寸
let VSHADER_SOURCE=
'attribute vec4 a_Position;\n' +
'attribute float a_PointSize;\n' +
'void main(){\n'+
'    gl_Position = a_Position;\n' +
'    gl_PointSize = a_PointSize;\n' +
'}\n'

//指定 点的颜色
let FSHADER_SOURCE = 
'void main(){\n' +
'    gl_FragColor = vec4(0.0,1.0,0.0,1.0);\n' +
'}\n'

function main(){
 
    
    initShaders(gl, VSHADER_SOURCE,FSHADER_SOURCE)

    //获取attribute变量的存储位置
    let a_Position = gl.getAttribLocation(gl.program, 'a_Position')
    let a_PointSize = gl.getAttribLocation(gl.program,'a_PointSize')
    
    if(a_Position < 0){
        console.log('Failed to get the storage location of a_Position')
        return
    }

    gl.vertexAttrib3f(a_Position, 0.5, 0.0, 0.0)
    gl.vertexAttrib1f(a_PointSize, 5.0)

    gl.clearColor(0, 0, 0, 1)
    gl.clear(gl.COLOR_BUFFER_BIT)
    gl.drawArrays(gl.POINTS, 0, 1)


}
